import request from '@/utils/request'

// 获取今日考勤记录
export function getTodayAttendance() {
  return request({
    url: '/api/attendances/today',
    method: 'get'
  })
}

// 获取所有用户的考勤记录
export function getAllAttendances(params) {
  return request({
    url: '/api/attendances/all',
    method: 'get',
    params
  })
}

// 获取考勤记录列表
export function getList(params) {
  return request({
    url: '/api/attendance',
    method: 'get',
    params
  })
}

// 获取考勤统计
export function getEmploeeAttentence(userId,startDate,endDate) {
  return request({
    url: `/api/attendances/user/${userId}/time`,
    method: 'get',
    params:{
      startDate,
      endDate
    }
  })
}

// 创建考勤记录
export function createRecord(data) {
  return request({
    url: '/api/attendance',
    method: 'post',
    data
  })
}

// 更新考勤记录
export function updateRecord(id, data) {
  return request({
    url: `/api/attendances/${id}`,
    method: 'put',
    data
  })
}

// 删除考勤记录
export function deleteRecord(id) {
  return request({
    url: `/api/attendances/${id}`,
    method: 'delete'
  })
}

// 批量删除考勤记录
export function batchDelete(ids) {
  return request({
    url: '/api/attendance/batch',
    method: 'delete',
    data: { ids }
  })
} 